/*

Copyright 2007 Renaun Erickson (http://renaun.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ignore
*/
package asfslib.api.familytree.v1
{
	
import mx.collections.ArrayCollection;
	
/**
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="searchHit">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="quality" type="{http://api.familysearch.org/familytree/v1}searchHitQuality" minOccurs="0"/>
 *         &lt;element name="score" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         &lt;element name="person" type="{http://api.familysearch.org/familytree/v1}searchPerson" minOccurs="0"/>
 *         &lt;element name="parent" type="{http://api.familysearch.org/familytree/v1}searchPerson" maxOccurs="unbounded" minOccurs="0"/>
 *         &lt;element name="spouse" type="{http://api.familysearch.org/familytree/v1}searchPerson" maxOccurs="unbounded" minOccurs="0"/>
 *         &lt;element name="child" type="{http://api.familysearch.org/familytree/v1}searchPerson" maxOccurs="unbounded" minOccurs="0"/>
 *       &lt;/sequence>
 *       &lt;attribute name="ref" type="{http://www.w3.org/2001/XMLSchema}string" />
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
public class SearchHit 
{

    //--------------------------------------------------------------------------
    //
    //  Constants
    //
    //--------------------------------------------------------------------------
    
    public static function parseXML(xml:XML):SearchHit
    {
		if (xml.namespace("") != undefined) 
		{
		    default xml namespace = xml.namespace("");
		}      	
	    var hit:SearchHit = new SearchHit();
		hit.score = xml.score;
		hit.ref = xml.@ref;
		hit.person = SearchPerson.parseXML(xml);
		// Create parent list
		var parents:Array = new Array();
		for each(var searchParent:XML in xml.parents.parent)
		{
			parents.push(SearchPerson.parseXML(searchParent));
		}
		hit.parents = new ArrayCollection(parents);	
		
		// Create spouses list
		var spouses:Array = new Array();
		for each(var searchSpouse:XML in xml.spouses.spouse)
		{
			spouses.push(SearchPerson.parseXML(searchSpouse));
		}
		hit.spouses = new ArrayCollection(spouses);		
		
		// Create children list
		var children:Array = new Array();
		for each(var searchChild:XML in xml.children.child)
		{
			children.push(SearchPerson.parseXML(searchChild));
		}
		hit.children = new ArrayCollection(children);	
				
		default xml namespace = new Namespace("");
		
    	return hit;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------    

    //----------------------------------
    //  quality
    //----------------------------------

    /**
     *  @private
     *  Storage for the quality property.
     */
    private var _quality:String = "";

    /**
     *  The quality property
     *
     *  @default  = ""
     */
    public function get quality():String
    {
        return _quality;
    }

    /**
     *  @private
     */
    public function set quality(value:String):void
    {
        _quality = value;
    }


    //----------------------------------
    //  score
    //----------------------------------

    /**
     *  @private
     *  Storage for the score property.
     */
    private var _score:int;

    /**
     *  The score property
     *
     *  @default 
     */
    public function get score():int
    {
        return _score;
    }

    /**
     *  @private
     */
    public function set score(value:int):void
    {
        _score = value;
    }


    //----------------------------------
    //  person
    //----------------------------------

    /**
     *  @private
     *  Storage for the person property.
     */
    private var _person:SearchPerson;

    /**
     *  The person property
     *
     *  @default 
     */
    public function get person():SearchPerson
    {
        return _person;
    }

    /**
     *  @private
     */
    public function set person(value:SearchPerson):void
    {
        _person = value;
    }


    //----------------------------------
    //  parents
    //----------------------------------

    /**
     *  @private
     *  Storage for the parents property.
     */
    private var _parents:ArrayCollection;

    /**
     *  The parents property
     *
     *  @default 
     */
    public function get parents():ArrayCollection
    {
        return _parents;
    }

    /**
     *  @private
     */
    public function set parents(value:ArrayCollection):void
    {
        _parents = value;
    }


    //----------------------------------
    //  spouses
    //----------------------------------

    /**
     *  @private
     *  Storage for the spouses property.
     */
    private var _spouses:ArrayCollection;

    /**
     *  The spouses property
     *
     *  @default 
     */
    public function get spouses():ArrayCollection
    {
        return _spouses;
    }

    /**
     *  @private
     */
    public function set spouses(value:ArrayCollection):void
    {
        _spouses = value;
    }


    //----------------------------------
    //  children
    //----------------------------------

    /**
     *  @private
     *  Storage for the children property.
     */
    private var _children:ArrayCollection;

    /**
     *  The children property
     *
     *  @default 
     */
    public function get children():ArrayCollection
    {
        return _children;
    }

    /**
     *  @private
     */
    public function set children(value:ArrayCollection):void
    {
        _children = value;
    }


    //----------------------------------
    //  ref
    //----------------------------------

    /**
     *  @private
     *  Storage for the ref property.
     */
    private var _ref:String = "";

    /**
     *  The ref property
     *
     *  @default  = ""
     */
    public function get ref():String
    {
        return _ref;
    }

    /**
     *  @private
     */
    public function set ref(value:String):void
    {
        _ref = value;
    }

}

}
